cmake_minimum_required(VERSION 3.20)

project(llvm-test)

include_directories(".")
include_directories("/usr/include/llvm-14")
include_directories("/usr/include/llvm-c-14")

link_directories("/usr/lib/llvm-14/lib")

add_library(slib STATIC slib.c)
add_library(dlib SHARED dlib.c)

add_executable(create_func create_func.cpp)
target_link_libraries(create_func LLVM)

add_executable(call_extern_func call_extern_func.cpp)
target_link_libraries(call_extern_func -Wl,--whole-archive slib  -Wl,--no-whole-archive LLVM)

add_executable(load_dylib_func load_dylib_func.cpp)
target_link_libraries(load_dylib_func LLVM)

add_executable(call_dylib_func call_dylib_func.cpp)
target_link_libraries(call_dylib_func dlib LLVM)

#add_executable(test main.cpp)
#target_link_libraries(test -Wl,--whole-archive slib  -Wl,--no-whole-archive dlib LLVM)

#set (CMAKE_ENABLE_EXPORTS TRUE)

add_executable(call_printf call_printf.cpp)
target_link_options(call_printf  PRIVATE -Wl,--export-dynamic)
target_link_libraries(call_printf LLVM)


add_executable(lli lli.cpp)
target_link_libraries(lli LLVM)
